package com.xwj.dao;

import com.xwj.domain.Item;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * 此处模拟数据库访问
 * @author xwj
 * @date 2020/4/27
 */
@Component
public class ItemDao {
    private static final Map<String, Item> item_table = new HashMap<>();
    static {
        item_table.put("1001", new Item(1, "1001", "三国演义", LocalDateTime.now()));
        item_table.put("2002", new Item(2, "2002", "红楼梦", LocalDateTime.now()));
        item_table.put("3003", new Item(3, "3003", "水浒传", LocalDateTime.now()));
        item_table.put("4004", new Item(4, "4004", "西游记", LocalDateTime.now()));
    }

    public Item getItemByCode(String code) {
        return item_table.get(code);
    }
}
